package com.ruibang.glass.equipment.controller;


import com.ruibang.glass.equipment.constant.Constants;
import com.ruibang.glass.equipment.domain.req.device.DeviceAllPageReq;
import com.ruibang.glass.equipment.entity.device.OutBoundManagement;
import com.ruibang.glass.equipment.entity.device.ScrapReport;
import com.ruibang.glass.equipment.service.OutBoundManagementService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
/**
 * <p>
 *出库管理
 * </p>
 *
 * @author mameng
 * @since 2024-03-20
 */
@RestController
@RequestMapping("/api/equipment/out/bound/management")
@Api(value = "出库管理")
public class OutBoundManagementController {
    @Autowired
    private OutBoundManagementService outBoundManagementService;

    @PostMapping("list")
    @ApiOperation(value = "仓库管理列表", response = ResultBody.class)
    public ResultBody getBoilerList(@RequestBody DeviceAllPageReq deviceAllPageReq) {
        return ResultBody.success(outBoundManagementService.queryPage(deviceAllPageReq));
    }

    @PostMapping("addOrUpdateCheck")
    @ApiOperation(value = "修改添加", response = ResultBody.class)
    public ResultBody addChild(@RequestBody OutBoundManagement repairWorkOrder) {
        return ResultBody.success(outBoundManagementService.updateOrAddById(repairWorkOrder));
    }


    @PostMapping("deleteAll")
    @ApiOperation(value = "删除", response = ResultBody.class)
    public ResultBody deleteAll(@RequestBody OutBoundManagement repairWorkOrder) {
        outBoundManagementService.lambdaUpdate().set(OutBoundManagement::getIsDelete, Constants.ONE_STR).eq(OutBoundManagement::getId, repairWorkOrder.getId()).update();
        return ResultBody.success(outBoundManagementService.removeById(repairWorkOrder.getId()));
    }


    @PostMapping("getOne")
    @ApiOperation(value = "查看详情", response = ResultBody.class)
    public ResultBody getOne(@RequestBody OutBoundManagement repairWorkOrder) {
        return ResultBody.success(outBoundManagementService.getById(repairWorkOrder.getId()));
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出", response = ResultBody.class)
    public void export(@RequestBody DeviceAllPageReq machiningReq, HttpServletResponse response) {
        outBoundManagementService.export(machiningReq, response);
    }
}
